✨ BCA JUL24 Batch ✨

Join Our WhatsApp Group

Anukasif Pic

3.2 - Loops - MCQs

Interactive MCQs Quiz

Test your knowledge with these questions

1. What is the purpose of a loop in programming?

2. Which of the following loops is a pre-tested loop?

3. What is the correct syntax for a for loop in C?

4. What happens when the condition in a while loop becomes false?

5. In a do-while loop, when is the condition checked?

6. What happens if the loop control variable is not incremented or decremented in a for loop?

7. Which loop guarantees that the loop body will execute at least once, even if the condition is false initially?

8. Which of the following loops is best suited for a situation where the number of iterations is not known in advance?

9. Which statement is true about nested loops?

10. What happens if the condition of a for loop is omitted?

11. Which loop type is used when a condition needs to be tested after executing the loop body?

12. What will happen in the following code?

int i = 10;
            while(i > 5) 
            {
                printf("%d", i);
            }

13. What is the default step value in a for loop if it is not explicitly specified?

14. Which of the following conditions can result in an infinite loop?

15. What should be established at the outset of a loop in order to prevent infinite execution?

16. What is the primary difference between a while loop and a for loop?

17. What is the condition for a loop to stop executing?

18. What is a "nested loop" in programming?

19. Which of the following is an example of a scenario where nested loops are typically used?

20. In the following structure of a nested loop, which loop runs first?

for (initialization; condition; increment/decrement) {
                // Outer loop code
                for (initialization; condition; increment/decrement) {
                    // Inner loop code
                }
            }

21. What does the following nested loop in C print?

for (int i = 1; i <= 2; i++) {
                    for (int j = 1; j <= 2; j++) {
                        printf("%d %d\n", i, j);
                    }
                }

22. In the example of printing a multiplication table, what is printed by the inner loop?

23. What is the purpose of the printf("\n"); statement in the multiplication table example?

24. How many times will the inner loop execute if the outer loop runs 10 times and the inner loop also runs 10 times?

25. In the multiplication table example, what does the expression i * j represent?

26. Which of the following is NOT a correct description of the use of nested loops?

27. What is the output of the following code snippet?

for (int i = 1; i <= 3; i++) {
                    for (int j = 1; j <= 2; j++) {
                        printf("%d ", i);
                    }
                }